import { CpcBase, ICpcBaseIos } from "../base/CpcBase";
import { CpcDrawerCtrl } from "../../../../components/CpcDrawer/CpcDrawerCtrl";
import { LeftRightAddBtn } from "../../widge/LeftRightAddBtn";

const ios: ICpcBaseIos = {
    inputs: [],
    outputs: [],
};

export class CpcRunCode extends CpcBase {
    public title = "代码编辑模块";

    public type = "CpcRunCode";

    protected codeEditDbShow = true;

    protected codeEidtReadOnly = false;

    constructor(title?: string) {
        super(ios, title);
        this.addCustomWidget(
            new LeftRightAddBtn({
                left: {
                    callback: this.leftAdd.bind(this),
                },
                right: {
                    callback: this.rightAdd.bind(this),
                },
            })
        );
    }

    public cpcRunCode(preDatas: any[], outputInfos: any[]): any[] {
        return [];
    }

    leftAdd() {
        const self = this;
        CpcDrawerCtrl.open(
            {
                component: "AEBasicField",
                data: this.getInputsNot0(),
                callBack(data: any, close: any) {
                    self.updateInputsNot0(data);
                    close();
                },
            },
            {
                title: "编辑输入节点",
                styleType: "center",
                isMaskEvent: false,
            }
        );
    }

    rightAdd() {
        const self = this;
        CpcDrawerCtrl.open(
            {
                component: "AEBasicField",
                data: this.getOutputsNot0(),
                callBack(data: any, close: any) {
                    self.updateOutputsNot0(data);
                    close();
                },
            },
            {
                title: "编辑输出节点",
                styleType: "center",
                isMaskEvent: false,
            }
        );
    }
}
